﻿using System.Web;
using CrazyTalk.Web.UI;

namespace CrazyTalk.Web.Actions
{
    /// <summary>
    /// Demo 的摘要说明
    /// </summary>
    public class Demo : UserHttpHandler
    {
        public Demo()
        {
            MenuId = 104;
        }

        public override void ProcessRequest(HttpContext context)
        {
            InHasPermission(); //
            context.Response.ContentType = "text/plain";
            string cmd = Query("cmd");
            if (string.IsNullOrEmpty(cmd))
            {
                context.Response.Write("访问错误");
                return;
            }
            switch (cmd)
            {
                    //删除用户
                case "del":
                    Delete();
                    break;
            }
        }

        /// <summary>
        /// 删除用户消息逻辑
        /// </summary>
        private void Delete()
        {
            if (HasPermission())
            {
                CurContext.Response.Write("无权限删除用户");
                Response.End();
            }
            string keyId = Query("id");
            if (string.IsNullOrEmpty(keyId))
            {
                CurContext.Response.Write("传入参数有误");
            }
            else
            {
                //只能删除发给自己的信息
                string errorMsg = string.Empty;

                //if (CmUserMessageBLL.Instance.Delete(ConvertUtil.ToInt(keyId), CurUserInfo.UserId, CurUserInfo.UserId))
                //{
                //    CurContext.Response.Write(string.Format("已成功删除信息", keyId));
                //}
                //else
                //{
                //    CurContext.Response.Write(string.Format("删除信息失败", keyId));
                //}
            }
        }
    }
}